﻿<?php 
include 'core/init.php';
logged_in_redirect();
include 'includes/overall/header.php';

if(isset($_GET['success']) === true && empty($_GET['success']) === true)	{
?>
		<div id="body-container">
		<h2><b> Takk, vi har nå aktivert din konto...</b></h2><br>
					<p id="p_black">Du kan nå logge inn!
<?php
}	else if(isset($_GET['email'], $_GET['email_code']) === true)	{
		$email			= trim($_GET['email']);
		$email_code	= trim($_GET['email_code']);
		
		if(email_exists($email) === false)	{
				$errors[] = 'Den emailen eksisterer ikke.';
		}	else if(activate($email, $email_code) === false)	{
				$errors[] = 'Vi hadde problemer med å aktivere din konto.';
		}
		
		if(empty($errors) === false)	{
		?>
				<h2>Oops...</h2>
		<?php
				echo output_errors($errors);
		}	else	{
				header('Location: activate.php?success');
				exit();
		}
		
}	else	{
		header('Location: index.php');
		exit();
}

include 'includes/overall/footer.php';
?>
